package com.ruoyi.web.controller.kzgl;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kzgl.domain.TbKzglDgddkz;
import com.ruoyi.kzgl.service.ITbKzglDgddkzService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电柜断电控制Controller
 * 
 * @author ruoyi
 * @date 2023-11-11
 */
@RestController
@RequestMapping("/kzgl/dgddkz")
public class TbKzglDgddkzController extends BaseController
{
    @Autowired
    private ITbKzglDgddkzService tbKzglDgddkzService;

    /**
     * 查询电柜断电控制列表
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dgddkz:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbKzglDgddkz tbKzglDgddkz)
    {
        startPage();
        List<TbKzglDgddkz> list = tbKzglDgddkzService.selectTbKzglDgddkzList(tbKzglDgddkz);
        return getDataTable(list);
    }

    /**
     * 导出电柜断电控制列表
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dgddkz:export')")
    @Log(title = "电柜断电控制", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbKzglDgddkz tbKzglDgddkz)
    {
        List<TbKzglDgddkz> list = tbKzglDgddkzService.selectTbKzglDgddkzList(tbKzglDgddkz);
        ExcelUtil<TbKzglDgddkz> util = new ExcelUtil<TbKzglDgddkz>(TbKzglDgddkz.class);
        util.exportExcel(response, list, "电柜断电控制数据");
    }

    /**
     * 获取电柜断电控制详细信息
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dgddkz:query')")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(tbKzglDgddkzService.selectTbKzglDgddkzByID(ID));
    }

    /**
     * 新增电柜断电控制
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dgddkz:add')")
    @Log(title = "电柜断电控制", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbKzglDgddkz tbKzglDgddkz)
    {
        return toAjax(tbKzglDgddkzService.insertTbKzglDgddkz(tbKzglDgddkz));
    }

    /**
     * 修改电柜断电控制
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dgddkz:edit')")
    @Log(title = "电柜断电控制", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbKzglDgddkz tbKzglDgddkz)
    {
        return toAjax(tbKzglDgddkzService.updateTbKzglDgddkz(tbKzglDgddkz));
    }

    /**
     * 删除电柜断电控制
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dgddkz:remove')")
    @Log(title = "电柜断电控制", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs)
    {
        return toAjax(tbKzglDgddkzService.deleteTbKzglDgddkzByIDs(IDs));
    }
}
